function handles = loadSetOfTracesNewEphys(handles)
% loadSetOfTracesNewEphys
%
% Mainly just a quick-and-dirty way to load the data into the 
% 'handles' variable
%
% Usage: First load a map acq'd with the old software.
% Then load a new set of map traces -- set trace type to
% 'ephys traces' and hit load. The handles.~.mapActive.bsArray
% field is over-written.
%
% Editing:
% gs August 2005
% --------------------------------------------------------------

[f p] = uigetfile('*.*', 'Select any trace.');
[pathstr, name, ext, versn] = fileparts([p f]);
d = dir(fullfile(pathstr, ['/*' ext]));
str = {d.name};
str = sortrows({d.name}');
[s,v] = listdlg('PromptString','Select a file:', 'OKString', 'OK',...
	'SelectionMode','multiple',...
	'ListString', str, 'Name', 'Select a File');
names = str(s);
numTraces = size(names, 1);
traceArray = [];
for n = 1 : numTraces
    fullfilename = fullfile(pathstr, names{n});
    s = load(fullfilename, '-mat');
    traceData = s.trace_1.data;
    traceArray = [traceArray traceData];
end
traceArray = traceArray * 1000;

% figure; plot(traceArray);
handles.data.map.map1.dataArray = traceArray;
return
% =========================================================================
% this is the function the above is based on, in part:
function names = selectFilesFromList(path, type)
global gh state

if nargin < 1
	path = pwd;
	type = '.tif'
end

if nargin == 1
	try
		filetype = get(gh.autotransformGUI.fileType, 'String');	
		value = get(gh.autotransformGUI.fileType, 'Value');
		filetype = filetype{value};
	catch
		filetype = type;
	end
end
if nargin == 2 
	filetype = type;
end

d = dir(fullfile(path, ['/*' filetype]));
if length(d) == 0
	str = 'No Files Found';
else
	str = {d.name};
end
str = sortrows({d.name}');
if isempty(str)
	names = {};
	disp('No Files with that Extension Selected. Please choose a Path with Image files');
	return
end

[s,v] = listdlg('PromptString','Select a file:', 'OKString', 'OK',...
	'SelectionMode','multiple',...
	'ListString', str, 'Name', 'Select a File');
names = str(s);